/**
 */
package fUML.Semantics.Activities.CompleteStructuredActivities;

import fUML.Semantics.Classes.Kernel.BooleanValue;

import fUML.Syntax.Activities.CompleteStructuredActivities.Clause;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EObject;

/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Clause Activation</b></em>'.
 * <!-- end-user-doc -->
 *
 * <!-- begin-model-doc -->
 * A clause activation defines the behavior of a clause within the context of a
 *                 specific activation of the conditional node containing the clause.
 * <!-- end-model-doc -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link fUML.Semantics.Activities.CompleteStructuredActivities.ClauseActivation#getClause <em>Clause</em>}</li>
 *   <li>{@link fUML.Semantics.Activities.CompleteStructuredActivities.ClauseActivation#getConditionalNodeActivation <em>Conditional Node Activation</em>}</li>
 * </ul>
 * </p>
 *
 * @see fUML.Semantics.Activities.CompleteStructuredActivities.CompleteStructuredActivitiesPackage#getClauseActivation()
 * @model
 * @generated
 */
public interface ClauseActivation extends EObject {
	/**
	 * Returns the value of the '<em><b>Clause</b></em>' reference.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Clause</em>' reference isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Clause</em>' reference.
	 * @see #setClause(Clause)
	 * @see fUML.Semantics.Activities.CompleteStructuredActivities.CompleteStructuredActivitiesPackage#getClauseActivation_Clause()
	 * @model required="true" ordered="false"
	 * @generated
	 */
	Clause getClause();

	/**
	 * Sets the value of the '{@link fUML.Semantics.Activities.CompleteStructuredActivities.ClauseActivation#getClause <em>Clause</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Clause</em>' reference.
	 * @see #getClause()
	 * @generated
	 */
	void setClause(Clause value);

	/**
	 * Returns the value of the '<em><b>Conditional Node Activation</b></em>' container reference.
	 * It is bidirectional and its opposite is '{@link fUML.Semantics.Activities.CompleteStructuredActivities.ConditionalNodeActivation#getClauseActivations <em>Clause Activations</em>}'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * The activation of the conditional node that contains the clause for this
	 *                   clause activation.
	 * <!-- end-model-doc -->
	 * @return the value of the '<em>Conditional Node Activation</em>' container reference.
	 * @see #setConditionalNodeActivation(ConditionalNodeActivation)
	 * @see fUML.Semantics.Activities.CompleteStructuredActivities.CompleteStructuredActivitiesPackage#getClauseActivation_ConditionalNodeActivation()
	 * @see fUML.Semantics.Activities.CompleteStructuredActivities.ConditionalNodeActivation#getClauseActivations
	 * @model opposite="clauseActivations" required="true" transient="false" ordered="false"
	 * @generated
	 */
	ConditionalNodeActivation getConditionalNodeActivation();

	/**
	 * Sets the value of the '{@link fUML.Semantics.Activities.CompleteStructuredActivities.ClauseActivation#getConditionalNodeActivation <em>Conditional Node Activation</em>}' container reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Conditional Node Activation</em>' container reference.
	 * @see #getConditionalNodeActivation()
	 * @generated
	 */
	void setConditionalNodeActivation(ConditionalNodeActivation value);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // If all predecessors to the clause for this activation have run their tests
	 *                   and failed, then run the test for this clause.
	 *  // If the test succeeds,
	 *                   then terminate any other clauses that may be running and run the body of this
	 *                   clause.
	 *  // If the test fails, then pass control to successor
	 *                   clauses.
	 *  
	 *  Debug.println("[receiveControl] clauseActivation = " +
	 *                   this);
	 *  
	 *  if (this.isReady()) {
	 *                   Debug.println("[receiveControl] Running test...");
	 *                   this.runTest();
	 *  
	 *  BooleanValue decision =
	 *                   this.getDecision();
	 *  
	 *  // Note that the decision may be null if
	 *                   the test was terminated before completion.
	 *  if (decision != null)
	 *                   {
	 *  if (decision.value == true) {
	 *  Debug.println("[receiveControl]
	 *                   Test succeeded.");
	 *  this.selectBody();
	 *  } else {
	 *                   Debug.println("[receiveControl] Test failed.");
	 *  
	 *                   ClauseActivationList successors = this.getSuccessors();
	 *  
	 *  // ***
	 *                   Give control to all successors concurrently. ***
	 *  for (Iterator i =
	 *                   successors.iterator(); i.hasNext();) {
	 *  ClauseActivation successor =
	 *                   (ClauseActivation)i.next();
	 *  successor.receiveControl();
	 *                   }
	 *  }
	 *  }
	 *  }
	 *  
	 * <!-- end-model-doc -->
	 * @model
	 * @generated
	 */
	void receiveControl();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Test if all predecessors to this clause activation have failed.
	 *                   
	 *  ClauseActivationList predecessors = this.getPredecessors();
	 *                   
	 *  boolean ready = true;
	 *  int i = 1;
	 *  while (ready
	 *                   & i <= predecessors.size()) { 
	 *  ClauseActivation
	 *                   predecessor = predecessors.getValue(i-1);
	 *  BooleanValue decisionValue =
	 *                   predecessor.getDecision();
	 *  
	 *  // Note that the decision will be
	 *                   null if the predecessor clause has not run yet.
	 *  if (decisionValue ==
	 *                   null) {
	 *  ready = false;
	 *  } else {
	 *  ready =
	 *                   !decisionValue.value;
	 *  }
	 *  
	 *  i = i + 1;
	 *  }
	 *                   
	 *  return ready;
	 *  
	 *  
	 * <!-- end-model-doc -->
	 * @model kind="operation" required="true" ordered="false"
	 * @generated
	 */
	boolean isReady();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Run the test of the clause for this clause activation.
	 *  
	 *                   this.conditionalNodeActivation.runTest(this.clause);
	 *  
	 * <!-- end-model-doc -->
	 * @model
	 * @generated
	 */
	void runTest();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Select the body of the clause for this clause activation.
	 *                   
	 *  this.conditionalNodeActivation.selectBody(this.clause);
	 *  
	 * <!-- end-model-doc -->
	 * @model
	 * @generated
	 */
	void selectBody();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Get the value (if any) on the decider pin of the clause for this clause
	 *                   activation.
	 *  
	 *  ValueList deciderValues =
	 *                   this.conditionalNodeActivation.getPinValues(this.clause.decider);
	 *                   
	 *  BooleanValue deciderValue = null;
	 *  if (deciderValues.size()
	 *                   > 0) {
	 *  deciderValue =
	 *                   (BooleanValue)(deciderValues.getValue(0));
	 *  }
	 *  
	 *  return
	 *                   deciderValue;
	 *  
	 * <!-- end-model-doc -->
	 * @model kind="operation" ordered="false"
	 * @generated
	 */
	BooleanValue getDecision();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Return the clause activations for the predecessors of the clause for this
	 *                   clause activation.
	 *  
	 *  ClauseActivationList predecessors = new
	 *                   ClauseActivationList();
	 *  
	 *  ClauseList predecessorClauses =
	 *                   this.clause.predecessorClause;
	 *  for (int i = 0; i <
	 *                   predecessorClauses.size(); i++) {
	 *  Clause predecessorClause =
	 *                   predecessorClauses.getValue(i);
	 *                   predecessors.addValue(this.conditionalNodeActivation.getClauseActivation(predecessorClause));
	 *                   }
	 *  
	 *  return predecessors;
	 *  
	 * <!-- end-model-doc -->
	 * @model kind="operation" ordered="false"
	 * @generated
	 */
	EList<ClauseActivation> getPredecessors();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Return the clause activations for the successors of the clause for this
	 *                   clause activation.
	 *  
	 *  ClauseActivationList successors = new
	 *                   ClauseActivationList();
	 *  
	 *  ClauseList successorClauses =
	 *                   this.clause.successorClause;
	 *  for (int i = 0; i <
	 *                   successorClauses.size(); i++) {
	 *  Clause successorClause =
	 *                   successorClauses.getValue(i);
	 *                   successors.addValue(this.conditionalNodeActivation.getClauseActivation(successorClause));
	 *                   }
	 *  
	 *  return successors;
	 *  
	 *  
	 * <!-- end-model-doc -->
	 * @model kind="operation" ordered="false"
	 * @generated
	 */
	EList<ClauseActivation> getSuccessors();

} // ClauseActivation
